<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html> 
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]--> 
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]--> 
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]--> 
<!-- BEGIN HEAD --> 
<head> 
	<title>抽奖结果 </title>
	<link href="${ctx}/resource/css/promo.css" rel="stylesheet" type="text/css"/> 
	<link href="${ctx}/resource/css/animate.css" rel="stylesheet" type="text/css"/> 
	<style type="text/css">

		.table td {line-height: 45px;}
		.avatar {width:43px;height:43px; border-radius:50px ! important;}
	</style>
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed page-full-width">
	<!-- 菜单及导航数据  -->
	
	
		<!-- 业务部分  开始  -->
     <div class="wrapper wrapper-content animated fadeInRight min-height">
        	<div class="row">
          <div class="col-lg-12">
              <div class="ibox float-e-margins">
                  <div class="ibox-title">
                      <h5>抽奖标题  ：<small class="text-navy">${lotteryEvent.title}</small></h5>
                      <div class="ibox-tools">
                          <a class="collapse-link">
                              <i class="fa fa-chevron-up"></i>
                          </a>
                          <a href="#" data-toggle="dropdown" class="dropdown-toggle">
                              <i class="fa fa-wrench"></i>
                          </a>
                          <ul class="dropdown-menu dropdown-user">
                              <li><a href="#">Config option 1</a>
                              </li>
                              <li><a href="#">Config option 2</a>
                              </li>
                          </ul>
                          <a class="close-link">
                              <i class="fa fa-times"></i>
                          </a>
                      </div>
                  </div>
                  <div class="ibox-content">
                     <table class="table table-responsive table-hover text-center">
                       <thead>
                         <tr class="info" style="font-weight: bold;">
							<td>奖项</td>
							<td>头像</td>
							<td>姓名</td>
							<td>mySingle</td>
							<td>手机号</td>
                         </tr>
                       </thead>
                       <tbody> 
                        <c:forEach items="${resultDtoList}" var="rec"  varStatus="status">
                			<tr class="item_${rec.orderNum }">
								<td>
									<c:choose>  
									    <c:when test="${fn:length(rec.lotteryName) > 10}">  
									        <vs:escape value="${fn:substring(rec.lotteryName, 0, 10)}..."	/> 
									    </c:when>  
									   <c:otherwise>  
									         <vs:escape value="${rec.lotteryName}"/> 
									    </c:otherwise>  
									</c:choose>  
								</td>
								<td>
									<img alt="${rec.uid }" src="${ctx }${rec.userImage }" class="avatar">
								</td>
								<td>
									<vs:escape value="${rec.name }" />
								</td>
								<td>
									<vs:escape value="${rec.uid }" />
								</td>
								<td>
									<vs:escape value="${rec.mobile }" />
								</td>
							</tr>
            		   </c:forEach>
                      </tbody>
                  </table>
				</div>
              	 <c:if test="${sessionScope.LOGINED_USER.uid eq lotteryEvent.uid}">
                  <div class="form-group text-left col-lg-4" id="btnId">
                      <button class="btn btn-block btn-outline btn-primary" type="button"><i class="fa fa-file-excel-o"></i>&nbsp;导出投票结果</button>
               	  </div>
               	</c:if>
              </div>
          </div>
      </div>
   	</div>
   	<form name="form1" target="_blank"></form>
   	
   	<js>
   	<script>
    $(":button").click(function(){
    	var load = layer.load(0);
    	$.ajax({
			type: "post",
			url: "${ctx}/lottery/exportExcel.do",
			data: "lid="+"${lotteryEvent.id }",
			dataType:"json",
			success:function(data){
				layer.close(load);
				if(data.status == 'error'){
					layer.msg("导出excel出现了问题，请联系管理员", {time: 2000, icon:6});
				}else{
					var a = '<p class="text-info">如果您的浏览器没有弹出下载框请点击<a href="${ctx}'+data.filePath+'" target="_blank">这里</a>下载</p>';
					$("#btnId").append(a);
					var form = $("[name='form1']");
					form.attr("action","${ctx}"+data.filePath);
					form.submit();
				}
			},
			error:function(d){
				layer.close(load);
				console.log(JSON.stringify(d));
			}
		});
    });
   	</script>
   	</js>
</body>
<!-- END BODY -->
</html>